package com.ycy.dubbo.impl;

import com.ycy.dubbo.client.TimeService;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 通过xml
 * 通过注解
 * 通过api
 */
@DubboService(version = "1.1.0")
public class TimeServiceImpl implements TimeService {

  Logger logger = LoggerFactory.getLogger(this.getClass());

  @Override
  public String getTimeout() {
    logger.info("getTime");
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
      //模拟业务每个方法 耗时2s
      Thread.sleep(2000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    return simpleDateFormat.format(new Date());
  }

  @Override
  public Long getTimestamp() {
    return new Date().getTime();
  }

}
